import java.util.Scanner;

public class Main {

    //前缀和解决大学里的树木要维护

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int m = scan.nextInt();

        long[] a = new long[n + 1];
        long[] sum = new long[n + 1];

        for(int i = 1; i <= n  ; i++){
            a[i] = scan.nextLong();
            sum[i] = sum[i - 1] + a[i];
        }

        for(int i = 1; i <= m; i++){
            int l = scan.nextInt();
            int r = scan.nextInt();
            System.out.println(sum[r] - sum[l - 1]);
        }
    }
}
